package ygflower.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
import ygflower.dao.FlowerDao;
import ygflower.dao.impl.JpaFlowerDao;
import ygflower.domain.Flower;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: lee
 * Date: 2010-2-2
 * Time: 21:50:23
 * To change this template use File | Settings | File Templates.
 */
public class ListFlowerController extends AbstractController {
    FlowerDao flowerDap;

    public static String ListFlowerView="ListFlowerView";
    public static String viewFlower = "flowers";

    public void setFlowerDap(FlowerDao flowerDap) {
        this.flowerDap = flowerDap;
    }
   @Override
    public ModelAndView handleRequestInternal(HttpServletRequest
  request, HttpServletResponse response)
            throws Exception {
        ModelAndView modelAndView = new ModelAndView(ListFlowerView);
        List<Flower>  listFlower = flowerDap.findAll();

        modelAndView.addObject("flowers" , listFlower);
        return modelAndView;  //To change body of implemented methods use File | Settings | File Templates.
    }
}
